package com.ruoyi.cooperation.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cooperation.domain.PwCooperation;
import com.ruoyi.cooperation.service.IPwCooperationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 合作加盟表Controller
 * 
 * @author ruoyi
 * @date 2025-07-26
 */
@RestController
@RequestMapping("/cooperation/cooperation")
public class PwCooperationController extends BaseController
{
    @Autowired
    private IPwCooperationService pwCooperationService;

    /**
     * 查询合作加盟表列表
     */
    @PreAuthorize("@ss.hasPermi('cooperation:cooperation:list')")
    @GetMapping("/list")
    public TableDataInfo list(PwCooperation pwCooperation)
    {
        startPage();
        List<PwCooperation> list = pwCooperationService.selectPwCooperationList(pwCooperation);
        return getDataTable(list);
    }

    /**
     * 导出合作加盟表列表
     */
    @PreAuthorize("@ss.hasPermi('cooperation:cooperation:export')")
    @Log(title = "合作加盟表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PwCooperation pwCooperation)
    {
        List<PwCooperation> list = pwCooperationService.selectPwCooperationList(pwCooperation);
        ExcelUtil<PwCooperation> util = new ExcelUtil<PwCooperation>(PwCooperation.class);
        util.exportExcel(response, list, "合作加盟表数据");
    }

    /**
     * 获取合作加盟表详细信息
     */
    @PreAuthorize("@ss.hasPermi('cooperation:cooperation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pwCooperationService.selectPwCooperationById(id));
    }

    /**
     * 新增合作加盟表
     */
    @PreAuthorize("@ss.hasPermi('cooperation:cooperation:add')")
    @Log(title = "合作加盟表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PwCooperation pwCooperation)
    {
        return toAjax(pwCooperationService.insertPwCooperation(pwCooperation));
    }

    /**
     * 修改合作加盟表
     */
    @PreAuthorize("@ss.hasPermi('cooperation:cooperation:edit')")
    @Log(title = "合作加盟表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PwCooperation pwCooperation)
    {
        return toAjax(pwCooperationService.updatePwCooperation(pwCooperation));
    }

    /**
     * 删除合作加盟表
     */
    @PreAuthorize("@ss.hasPermi('cooperation:cooperation:remove')")
    @Log(title = "合作加盟表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pwCooperationService.deletePwCooperationByIds(ids));
    }
}
